<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/icon.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/ainit.css" type="text/css"></link>
 	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.4.min.js"></script>
 	<script type="text/javascript" src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/homepages/js/functions.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.1.2.2.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.ainit-1.0.0.js"></script>
	<script type="text/javascript">
		var a = document.documentElement.clientHeight - 72;
		var b = document.documentElement.clientWidth - 25;
		$(function(){
			loadPages();
			loadButns();
			loadDategrid();
			saveXT();
		});
		
		var divName="";
		//加载查询条件或当前界面的主表信息     传入参数colId(界面配置的总DS_ID)
		function loadPages(){
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/framework/columnList',
				data:{'colId':'db_project','flag':'T'}, 
				success:function(data){
					if(data ==""){
						alert("数据为空");
					}else{
						//请求一个组织列的方法
						divName='COLUMNS';
						makeColumns(data,divName);
					}
				}
			});
		}
		//加载按钮  传入参数butnId
		function loadButns(){
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/framework/buttonsList',
				data:{'butnId':'fin_cost'},
				success:function(data){
					if(data == ""){
						alert("按钮数据为空");
					}else{
						//请求一个组织按钮的方法
						var buttons = data;
						var butHTML = "";
						for(var i = 0; i < buttons.length; i++){
							butHTML += formatButtons(buttons[i]);
						}
						$('#BUTTONS').html(butHTML);
						$.parser.parse();  //重新编译界面
					}
				}
			})
		}
		//加载datagrid  传入参数dsId(配置DS的数据源ID)；colId（//加载查询条件或当前界面的主表信息     传入参数colId）
		function loadDategrid(){
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/framework/listQueryJson',
				data:{'dsId':'db_project','colId':'db_project'},
				success:function(data){
					if(data==""){
						alert("数据为空");
					}else{
						//给datagrid赋列值，还有rows
						mdatagrid(data);
					}
				}
			})
		}
		//组合datagrid信息  不用改任何信息
		function mdatagrid(data){ //传入的是queryJson 里面就有columns和rows
			var lastIndex;
			$('#DATALIST').datagrid({
				iconCls:'icon-save',
				nowrap: false,
				striped: true,				 
				collapsible:true,
				autoRowHeight: false,		
				sortOrder: 'desc',
				remoteSort: false,
				fitColumns:true,
				columns:[[]],
				pagination:true,
				rownumbers:true,
				singleSelect:true,
				onDblClickRow:function(rowIndex,rowData){
					
				}
			});
			var dataGrid = $('#DATALIST');
			dataGrid.datagrid(jointColumn(data.columns));//根据配置选项，生成datagrid  
			//alert(data.rows.length);
			$('#DATALIST').datagrid("loadData", data);
		}
		
		
		//添加按钮时的方法
 		function showAddWin(){
 			$('#makeColumn input').each(function(){
				if($(this).attr('nowrite') == 'true'){
					$(this).removeAttr('readonly');
				}
			});
 			$('#applyTopic').dialog('open');
 		}
 		
 		//添加按钮时,调用的方法   传入参数colId（//加载查询条件或当前界面的主表信息     传入参数colId）；butnId(添加按钮的按钮编码)；
		function saveXT(){
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/framework/singlePage',
				data:{'colId':'db_project','flag':'','butnId':'bs_product'},
				success:function(data){
					if(data ==""){
						alert("数据为空");
					}else{
					 	divName='makeColumn';
						makeColumns(data.columns,divName);
						var buttons = data.buttons;
						var butHTML = "";
						for(var i = 0; i < buttons.length; i++){
							butHTML += formatButtons(buttons[i]);
						}
						$('#makeButton').html(butHTML);
						$.parser.parse();  //重新编译界面
					}
				}
			});
			$('#applyTopic').dialog({
				width:850,
				height:550,
				collapsible: true,
				minimizable: true,
				maximizable: true,
				title:'添加选题',
				left:150,
				top:10
			});
			$('#applyTopic').dialog('close');
			
		}
	</script>
</head>
<body  onresize="resizeGrid();">
	<form action="" method="post" id="queryForm">
		<table cellpadding="0" cellspacing="0" style="width: 100%">
			<tr>
				<td>
					<!-- 部分查询框 -->
					<table id="COLUMNS">
					</table>
				</td>
				<td style="vertical-align: top;">
					<!-- 部分按钮 -->
					<div id="BUTTONS" style="width:195px;padding-left: 20px;"></div>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<!-- 数据列表 -->	
					<table  id="DATALIST"></table>
				</td>
			</tr>
		</table>
	</form>
	<div id="applyTopic" >
		<table cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<!--录入框 -->
					<table id="makeColumn">
					</table>
				</td>
			</tr>
			<tr>
				<td style="vertical-align: top;">
					<!-- 部分按钮 -->
					<div id="makeButton" style="width:195px;padding-left: 20px;"></div>
				</td>
			</tr>
		</table>
	</div>  <!-- 添加按钮点击弹出添加界面 -->
	<input type="hidden" id="configId" value="${configId}"/>
	<input type="hidden" id="funcsId" value="${funcsId}"/>
</body>
</html>